<%-- 
    Document   : edit
    Created on : Apr 24, 2010, 6:40:25 PM
    Author     : Пользователь
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>

<%@taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
<%@taglib prefix="h" uri="http://java.sun.com/jsf/html"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">

<f:view locale="#{locale.locale}">
    <f:loadBundle basename="ru.ssau.berlin.jsf.i18n.Messages" var="bundle"/>
    <html>
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
            <title><h:outputText value="#{bundle.ssau_manage_system} :: #{bundle.group_type}"/></title>
        </head>
        <body>
            <small>
                <h:form>
                    <h:commandLink action="#{locale.setLocale}" value="en">
                        <f:param name="locale" value="en"/>
                    </h:commandLink> |
                    <h:commandLink action="#{locale.setLocale}" value="ru">
                        <f:param name="locale" value="ru"/>
                    </h:commandLink>
                </h:form>
            </small>
            <h1><h:outputText value="#{bundle.group_type}"/></h1>
            <h:form>
                <h:panelGrid columns="2">
                    <h:outputText value="#{bundle.id}:"/>
                    <h:outputText value="#{groupType.type.id}"/>
                    <h:outputLabel for="name" value="#{bundle.name}:"/>
                    <h:inputText id="name" value="#{groupType.type.name}"
                                 readonly="#{groupType.readonly}"/>
                    <h:outputLabel for="parent" value="#{bundle.parent}:"/>
                    <h:selectOneMenu id="parent"
                                     value="#{groupType.type.parent}"
                                     readonly="#{groupType.readonly}"
                                     rendered="#{not empty groupType.types}"
                                     converter="berlin.GroupTypeConverter">
                        <f:selectItems value="#{groupType.items}"/>
                    </h:selectOneMenu>
                </h:panelGrid>
                <h:commandButton action="#{groupType.persist}"
                                 value="#{bundle.save}" rendered="#{not groupType.readonly}">
                    <f:param name="id_param" value="#{groupType.type.id}"/>
                </h:commandButton>
                <h:commandButton actionListener="#{groupType.delete}"
                                 value="#{bundle.delete}" action="#{groupType.showAll}"
                                 rendered="#{groupType.type.id != null}">
                    <f:attribute name="id_param" value="#{groupType.type.id}"/>
                </h:commandButton>
                <h2><h:outputText value="#{bundle.attributes}" rendered="#{groupType.type.id != null}"/></h2>
                <h:dataTable value="#{groupType.type.attributes}" var="attr" border="1"
                             title="#{bundle.attributes}" rendered="#{groupType.type.id != null}">
                    <h:column>
                        <f:facet name="header">
                            <h:outputText value="#{bundle.id}"/>
                        </f:facet>
                        <h:outputText value="#{attr.id}"/>
                    </h:column>
                    <h:column>
                        <f:facet name="header">
                            <h:outputText value="#{bundle.name}"/>
                        </f:facet>
                        <h:outputText value="#{attr.name}"/>
                    </h:column>
                    <h:column>
                        <f:facet name="header">
                            <h:outputText value="#{bundle.type}"/>
                        </f:facet>
                        <h:outputText value="#{attr.type}"/>
                    </h:column>
                    <h:column rendered="#{!groupType.readonly}">
                        <f:facet name="header">
                            <h:outputText value="#{bundle.actions}"/>
                        </f:facet>
                        <h:commandLink action="#{groupType.showAttribute}" value="#{bundle.show}">
                            <f:param name="id_param" value="#{attr.id}"/>
                        </h:commandLink> |
                        <h:commandLink action="#{groupType.editAttribute}" value="#{bundle.edit}">
                            <f:param name="id_param" value="#{attr.id}"/>
                        </h:commandLink> |
                        <h:commandLink action="#{groupType.unbindAttribute}" value="#{bundle.unbind}">
                            <f:param name="id_param" value="#{attr.id}"/>
                        </h:commandLink>
                    </h:column>
                </h:dataTable>
                <h:selectOneMenu value="#{groupType.attr}"
                                 rendered="#{not groupType.readonly
                                             and groupType.type.id != null
                                             and not empty groupType.attrItems}"
                                 converter="berlin.GroupAttributeConverter">
                    <f:selectItems value="#{groupType.attrItems}"/>
                </h:selectOneMenu>
                <h:commandButton action="#{groupType.addAttribute}"
                                 value="#{bundle.add} #{bundle.attribute}"
                                 rendered="#{not groupType.readonly
                                             and groupType.type.id != null
                                             and not empty groupType.attrItems}">
                    <f:param name="id_param" value="#{groupType.type.id}"/>
                </h:commandButton>
                <h:commandButton action="#{groupType.createAttribute}"
                                 value="#{bundle.new_attribute}"
                                 rendered="#{not groupType.readonly and groupType.type.id != null}">
                    <f:param name="id_param" value="#{groupType.type.id}"/>
                </h:commandButton>
            </h:form>
            <h:form>
                <h2><h:outputText value="#{bundle.navigation}"/></h2>
                <h:commandLink action="#{groupType.showAll}" value="#{bundle.types_list}"/> <br/>
                <h:commandLink action="#{navigator.goToMainPage}" value="#{bundle.home}"/>
            </h:form>
        </body>
    </html>
</f:view>
